#include <stdio.h>
#include <string.h>
typedef struct
{
    int id;
    char name[20];
    int age;
}student;
int main()
{   
    //文件指针
    FILE*fr = fopen("文件编程","r");
    FILE*fw = fopen("test.txt","w");

    if(fr == NULL)
    {
        printf("文件打开失败!\n");
        return -1;
    }
     if(fw == NULL)
    {
        printf("文件打开失败!\n");
        return -1;
    }
   student stu;
   stu.id = 1;
   strcpy(stu.name,"zhangsan");
   stu.age = 20;

   //把一个结构体放入文件中
   fprintf(fw,"%d %s %d",stu.id,stu.name,stu.age);
    
    fclose(fr);
    fclose(fw);
    return 0;
}